package com.sunwhite.jdbc.MyJdbc;

import com.sunwhite.jdbc.MyJdbc.advise.ConnectionAdvise;
import com.sunwhite.jdbc.MyJdbc.interfaces.MyJdbc;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

public class MyJdbcFaction {
  public static MyJdbc MyJdbcFaction(Class classFile) throws Exception {
    MyJdbc myJdbc = (MyJdbc) classFile.newInstance();
    InvocationHandler invocation = new ConnectionAdvise(myJdbc);
    MyJdbc proxy =
        (MyJdbc)
            Proxy.newProxyInstance(
                myJdbc.getClass().getClassLoader(), myJdbc.getClass().getInterfaces(), invocation);
    return proxy;
  }
}
